/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package riteservices.model.dao;

import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import riteservices.model.bean.Route;

/**
 *
 * @author sixviv
 */
public class RouteDAO extends GeneralDAO <Route>{
    
    public Route getRouteById(long routeid){
        List<Route> rute = search("idRoute="+routeid,Route.class);
        if(!rute.isEmpty()){
            return rute.get(0);
        }else{
            return null;
        }
    }
    
    public List<Route> getRoutesByOrigin(String term)
    {
        List<Route> list = search("origin like '"+term+"%'", Route.class);
        return list;
    }
    
    public List<Route> getRoutesByDestiny(String term)
    {
        List<Route> list = search("destiny like '"+term+"%'", Route.class);
        return list;
    }


}
